package com.jewel.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.jewel.service.IndexService;


@Controller
public class IndexController {

    @Autowired
    private IndexService indexService;

    /**
     * 主页产品展示
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("products", this.indexService.getAllProduct());

        modelAndView.setViewName("index");
        return  modelAndView;
    }
}
